package com.xmy.cultivate.controller;

import com.xmy.cultivate.service.IStudentTypeService;
import com.xmy.cultivate.util.Code;
import com.xmy.cultivate.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 是否新生 前端控制器
 * </p>
 *
 * @author min
 * @since 2022-11-28
 */
@RestController
@RequestMapping("/api/studentType")
public class StudentTypeController {

    @Autowired
    IStudentTypeService iStudentTypeService;

    /**
     * 切换状态（新生或者老生）
     * @return
     */
    @PutMapping("cutType/{schoolId}/{studentId}/{subjectsId}/{isNewStudent}")
    public Result cutType(@PathVariable(value = "schoolId") Long schoolId,@PathVariable(value = "studentId") Long studentId,@PathVariable(value = "subjectsId") Long subjectsId,@PathVariable(value = "isNewStudent") Integer isNewStudent){
        try{

            boolean rs = iStudentTypeService.seType(schoolId,studentId,subjectsId,isNewStudent);

            return new Result(rs? Code.OK:Code.ERROR);
        }catch (Exception e){
            return new Result(Code.ERROR,e.getMessage());
        }
    }
}
